# Maintainer: Ricky Wu <rickleaf.wu@gmail.com>
# Contributor: ImperatorS79 <fevrier.simon@gmail.com>

_realname=luarocks
pkgbase=mingw-w64-lua-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-lua-${_realname}")
pkgver=3.4.0
pkgrel=1
pkgdesc="the package manager for Lua modules (mingw-w64)"
arch=('any')
url="https://luarocks.org"
license=("MIT")
depends=("${MINGW_PACKAGE_PREFIX}-lua")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "unzip")
options=('staticlibs' 'strip')
source=("https://luarocks.org/releases/${_realname}-${pkgver}.tar.gz")
sha256sums=('62ce5826f0eeeb760d884ea8330cd1552b5d432138b8bade0fa72f35badd02d0')

prepare() {
  plain 'No Step'
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ./configure --prefix=${MINGW_PREFIX} --lua-version=5.3 --with-lua-interpreter=lua.exe
  make ./build/luarocks ./build/luarocks-admin ./build/config-5.3.lua
  make LUA_VERSION=5.1 LUA_INTERPRETER=lua5.1.exe LUA_INCDIR=${MINGW_PREFIX}/include/lua5.1 ./build/config-5.1.lua
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  make DESTDIR="$pkgdir" LUA_VERSION=5.1 install-config
}
